package messageHistoryDao

import (
	"chart.zozoo.net/app/models"
	"chart.zozoo.net/core/mysql"
	"errors"
	"gorm.io/gorm"
)

// Find 获取好友聊天列表
func Find(uid int) (list []*models.MessageHistory, err error) {
	list = make([]*models.MessageHistory, 0)
	res := mysql.MysqlClient.
		Select("id,f_uuid,msg_view,unread_num,created_at").
		Where("uid=?", uid).
		Find(&list)
	if res.Error != nil && !errors.Is(res.Error, gorm.ErrRecordNotFound) {
		return nil, res.Error
	}
	return
}
